package com.jiangjun.fetch.util;

import java.util.Calendar;
import java.util.Date;

public class DateUtil {

	/**
	 * 根据格林制时间获取毫秒数
	 * 
	 * @param GMTime
	 *            格林制时间
	 * @return 毫秒数
	 */
	@SuppressWarnings("deprecation")
	public static long getMills(String GMTime) {
		long time = new Date(GMTime).getTime();
		return time;
	}

	/**
	 * 获取格林时间
	 * 
	 * @return 格林时间
	 */
	@SuppressWarnings("deprecation")
	public static String getGMTdate() {
		Date d = new Date();
		String localDate = d.toString();
		String date = localDate.substring(0, 3) + ", " + d.toGMTString();
		return date;
	}

	/**
	 * 根据毫秒数获取格林时间
	 * 
	 * @param time
	 *            毫秒数
	 * @return 格林时间
	 */
	@SuppressWarnings("deprecation")
	public static String getGMTdate(long time) {
		Date d = new Date();
		d.setTime(time);
		String week = d.toString().substring(0, 3);
		String date = week + ", " + d.toGMTString();
		return date;
	}

	public static String getGMTdate2Expires() {
		Calendar c = Calendar.getInstance();
		c.add(Calendar.SECOND, 1);
		Date date = c.getTime();
		String time = date.toString().substring(0, 3) + ", "
				+ c.getTime().toGMTString();
		return time;
	}

}
